package com.snapan.vo;

/**
 * 统一返回结果类
 */
public class BaseResponse {
    /**
     * 是否成功
     */
    private boolean success;

    /**
     * 返回消息
     */
    private String message;

    /**
     * 返回数据
     */
    private Object data;

    /**
     * 状态码（可选）
     */
    private Integer code;

    // 构造方法
    public BaseResponse() {
    }

    public BaseResponse(boolean success, String message) {
        this.success = success;
        this.message = message;
    }

    public BaseResponse(boolean success, String message, Object data) {
        this.success = success;
        this.message = message;
        this.data = data;
    }

    public BaseResponse(boolean success, String message, Object data, Integer code) {
        this.success = success;
        this.message = message;
        this.data = data;
        this.code = code;
    }

    // 成功静态方法
    public static BaseResponse success(String message) {
        return new BaseResponse(true, message);
    }

    public static BaseResponse success(String message, Object data) {
        return new BaseResponse(true, message, data);
    }

    public static BaseResponse success(String message, Object data, Integer code) {
        return new BaseResponse(true, message, data, code);
    }

    // 失败静态方法
    public static BaseResponse error(String message) {
        return new BaseResponse(false, message);
    }

    public static BaseResponse error(String message, Object data) {
        return new BaseResponse(false, message, data);
    }

    public static BaseResponse error(String message, Object data, Integer code) {
        return new BaseResponse(false, message, data, code);
    }

    // Getter 和 Setter 方法
    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    @Override
    public String toString() {
        return "BaseResponse{" +
                "success=" + success +
                ", message='" + message + '\'' +
                ", data=" + data +
                ", code=" + code +
                '}';
    }
}